package com.yupi.usercenter.common;

import java.io.Serializable;

/**
 * 后端统一返回结果
 */
public class Result implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer code; // 编码：1成功，0为失败
    private String msg; // 错误信息
    private Object data; // 数据

    public Result() {
    }

    public static Result success() {
        Result result = new Result();
        result.setCode(1);
        result.setMsg("success");
        return result;
    }

    public static Result success(Object object) {
        Result result = new Result();
        result.setData(object);
        result.setCode(1);
        result.setMsg("success");
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(0);
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}